<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>新添书籍</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="author" content="夜读书">
    <meta name="description" content="夜读书中文网">
    <meta name="keywords" content="读书,阅读,小说,文学">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="{{ asset('/bootstrap-3.3.5-dist/css/bootstrap.min.css') }}">
    <link rel="stylesheet" href="{{ asset('/style/css/yds.css') }}">
    <link rel="stylesheet" href="{{ asset('/style/css/ucenter.css') }}">
    <script src="{{ asset('/scripts/jquery/jquery-1.11.3.min.js') }}"></script>
    <script src="{{ asset('/bootstrap-3.3.5-dist/js/bootstrap.min.js') }}"></script>
    {{-- umeditor --}}
    <script type="text/javascript" charset="utf-8" src="{{ asset('/editor/uaddbk_ueditor1_4_3_1/ueditor.config.js') }}"></script>
    <script type="text/javascript" charset="utf-8" src="{{ asset('/editor/uaddbk_ueditor1_4_3_1/ueditor.all.js') }}"> </script>
    <script type="text/javascript" charset="utf-8" src="{{ asset('/editor/uaddbk_ueditor1_4_3_1/lang/zh-cn/zh-cn.js') }}"></script>
    {{-- umeditor end--}}
</head>
<body>
@include('books.partials.navtop')
@include('books.partials.nav')
<div id="yds_screen">
<div id="yds_content" class="clearfix">
  <div class="article">
   <h1>添加 <strong>{{trim($bookname)}}</strong> 的书籍信息</h1>
    <form name="form" class="form-horizontal" role="form" method="post" action="saveuaddbooks" enctype="multipart/form-data">
     <input type="hidden" name="_token" value="{{ csrf_token() }}" />
    <div class="form-group">
      <label for="bookname" class="col-sm-2 control-label">书名:*</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" name="bookname" id="bookname" maxlength="120" value="{{trim($bookname)}}" style="float:left;width:400px;background: #FFFCDF none repeat scroll 0% 0%;">
      </div>
    </div>
    <div class="form-group">
      <label for="fenmian" class="col-sm-2 control-label">图书封面：</label>
      <div class="col-sm-10">
        <input type="file" id="fengmian" name="fengmian">
        <p class="help-block">上传图书封面图片,从你的电脑上选择图片... </p>
      </div>
    </div>
    <div class="form-group">
      <label for="yuanzuoming" class="col-sm-2 control-label">原作名：</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" name="yuanzuoming" id="yuanzuoming" value="" style="float:left;width:400px">
      </div>
    </div>
    <div class="form-group">
      <label for="fubiaoti" class="col-sm-2 control-label">副标题：</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" name="fubiaoti" id="fubiaoti" value="" style="float:left;width:400px">
      </div>
    </div>
    <div class="form-group">
      <label for="isbn" class="col-sm-2 control-label">ISBN：*</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" name="isbn" id="isbn" readonly="readonly" value="{{trim($isbn)}}" style="float:left;width:400px">
      </div>
    </div>
    <div class="form-group">
      <label for="catname" class="col-sm-2 control-label">分类：*</label>
      <div class="col-sm-10">
          <select class="form-control" name="catname" id="catname" style="width:150px">
          <option selected value="0">请选择分类</option>
          @foreach ($cats as $cat)
          <option value="{{$cat->cat_id}}">{{$cat->cat_name}}</option>
          @endforeach
          </select>
      </div>
    </div>
    <div class="form-group">
      <label for="zuozhe" class="col-sm-2 control-label">作者：*</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" name="zuozhe" id="zuozhe" value="" style="float:left;width:400px"><span style="float:right;padding:7px 10px;"> 如: [英] J. K. 罗琳</span>
      </div>
    </div>
    <div class="form-group">
      <label for="yizhe" class="col-sm-2 control-label">译者：</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" name="yizhe" id="yizhe" value="" style="float:left;width:400px">
      </div>
    </div>
    <div class="form-group">
      <label for="chubanshe" class="col-sm-2 control-label">出版社：</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" name="chubanshe" id="chubanshe" value="" style="float:left;width:400px">
      </div>
    </div>
    <div class="form-group">
      <label for="chubannian" class="col-sm-2 control-label">出版年：</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" name="chubannian" id="chubannian" value="" style="float:left;width:150px"><span style="padding:7px 160px;display:block;">如: 2015-11-19</span>
      </div>
    </div>
    <div class="form-group">
      <label for="yeshu" class="col-sm-2 control-label">页数：</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" name="yeshu" id="yeshu" value="" style="float:left;width:65px"><span style="padding:7px 70px;display:block;">页</span>
      </div>
    </div>
    <div class="form-group">
      <label for="zhuangzhen" class="col-sm-2 control-label">装帧：</label>
      <div class="radio">
      <label>
      <input type="radio" name="zhuangzhen" id="zhuangzhen" value="平装">平装
      </label>
      <label>
      <input type="radio" name="zhuangzhen" id="zhuangzhen" value="精装">精装
      </label>
      <label>
      <input type="radio" name="zhuangzhen" id="zhuangzhen" value="0">其他：</label><input type="text" class="form-control" name="zzqita" id="zzqita" maxlength="20" value="" style="width:100px">
      </div>      
    </div>
    <div class="form-group">
      <label for="dingjia" class="col-sm-2 control-label">定价：</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" name="dingjia" id="dingjia" value="" style="float:left;width:65px"><span style="padding:7px 70px;display:block;">元</span>
      </div>
    </div>    
    <div class="form-group">
      <label for="congshu" class="col-sm-2 control-label">丛书：</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" name="congshu" id="congshu" value="" style="float:left;width:400px">
      </div>
    </div>
    <div class="form-group">
      <label for="neirongjianjie" class="col-sm-2 control-label">内容简介:*</label>
      <div class="col-sm-10">
        <script type="text/plain" id="neirongjianjie" name="neirongjianjie" style="width:100%;height:240px;"></script>
      </div>
    </div>
    <div class="form-group">
      <label for="zuozhejianjie" class="col-sm-2 control-label">作者简介：</label>
      <div class="col-sm-10">
        <script type="text/plain" id="zuozhejianjie" name="zuozhejianjie" style="width:100%;height:240px;"></script>
      </div>
    </div>
    <div class="form-group">
      <label for="mulu" class="col-sm-2 control-label">目录简介：</label>
      <div class="col-sm-10">
        <script type="text/plain" id="mulu" name="mulu" style="width:100%;height:240px;"></script>
      </div>
    </div>    
      <div>
        <button type="button" id="okbutton" class="btn btn-success" style="float:right">添加图书</button>
      </div>
    <script type="text/javascript">
    //实例化编辑器
    var ueneirongjianjie = UE.getEditor('neirongjianjie');
    var uezuozhejianjie = UE.getEditor('zuozhejianjie');
    var uemulu = UE.getEditor('mulu');    
    </script>
    </form>
  </div>
  <div class="aside">
  <div class="indent">
    <span class="">完善书籍资料...</span>
    <p>请尽量使填写的信息内容和书籍本身一致，在格式上请参照输入框右侧的样例。</p>
    <p>请尽量选择象素较高的封面图片。</p>
    <p>请准确填写图书信息，信息不正确可能影响审核和收录。</p>
  </div>
  </div>
</div>
</div>
<script>
$(document).ready(function(){
    $("#okbutton").click(function(){
        if($.trim($("#bookname").val())=="")
        {
            alert("请输入书籍的名字。");
            $("#bookname").focus();
        }
        else if($.trim($("#isbn").val())=="")
        {
            alert("请输入书籍的ISBN。");
            $("#isbn").focus();
        }
        else if($.trim($("#catname").val())==0)
        {
            alert("请选择书籍分类。");
            $("#catname").focus();
        }
        else if($.trim($("#zuozhe").val())=="")
        {
            alert("请输入书籍的作者。");
            $("#zuozhe").focus();
        }
        else if(!UE.getEditor('neirongjianjie').hasContents())
        {
            alert("请输入书籍的内容介绍");
            UE.getEditor('neirongjianjie').focus();
        }
        else if($.trim($("#fengmian").val())=="")
        {
            alert("请上传书籍封面图片");
            $("#fengmian").focus();
        }
        else if($.trim($("#fengmian").val())!=="")
        {
            //判断上传文件格式
            var FileName=new String($("#fengmian").val()); //文件名
            var extension=new String(FileName.substring(FileName.lastIndexOf(".")+1,FileName.length)); //文件扩展名
            if(!(extension=="jpg"||extension=="png"||extension=="gif"||extension=="jpeg"))
            {
                alert("书籍封面图片格式不正确，\n只可以上传 jpg,jpeg,png,gif 格式的图片文件！");
            }            
            else
            {
                form.submit();
            }
        }
        else
        {
            form.submit();
        }
    });
});
</script>
@include('books.partials.footer')
</body>
</html>
